import pyautogui
import time
import pyperclip
import subprocess

class IntelligentControlSystem:
    def __init__(self):
        pass

    def open_website(self, url):
        print(f"Opening website: {url}")
        subprocess.Popen(['start', 'chrome', url], shell=True)
        time.sleep(5)  # 等待浏览器打开并加载页面

    def search_information(self, query):
        print(f"Searching for: {query}")
        pyautogui.write(query, interval=0.1)  # 设置每个字符之间的延迟
        pyautogui.press('enter')

    def get_clipboard_text(self):
        text = pyperclip.paste()
        print(f"Clipboard text: {text}")
        return text

if __name__ == '__main__':
    system = IntelligentControlSystem()
    # system.open_website("https://www.google.com")
    system.open_website("https://cn.bing.com/")
    time.sleep(2)  # 等待页面加载
    clipboard_text = system.get_clipboard_text()
    system.search_information(clipboard_text)
    time.sleep(2)  # 等待搜索结果加载
    print(f"Text from clipboard: {clipboard_text}")